{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "女人成功,背后大多有一个不成功的男人\n",
      "男人失败时，闷头喝酒，谁也不用说\n",
      "女人失败,眼泪汪汪，谁也说不了\n",
      "男人恋爱时，凡是不懂也要装懂\n",
      "女人恋爱时，懂事情也要装不懂\n"
     ]
    }
   ],
   "source": [
    "\n",
    "def printinfo(info):\n",
    "    print(info)\n",
    "class person():\n",
    "    def accept(self,visitor):\n",
    "        pass\n",
    "class man(person):\n",
    "    type='男人'\n",
    "    def accept(self,visitor):\n",
    "        visitor.getmanconclusion(self)\n",
    "class woman(person):\n",
    "    type='女人'\n",
    "    \n",
    "    def accept(self,visitor):\n",
    "        visitor.getwomanconclusion(self)\n",
    "        \n",
    "class action():\n",
    "    def getmanconclusion(self,person):\n",
    "        pass\n",
    "    def getwomanconclusion(self,persion):\n",
    "        pass\n",
    "class success(action):\n",
    "    type='成功'\n",
    "    def manconclusion(self,person):\n",
    "        printinfo('%s%s时，背后多半有一个伟大的女人'%(person.type,self.type))\n",
    "    def getwomanconclusion(self,person):\n",
    "        printinfo('%s%s,背后大多有一个不成功的男人'%(person.type,self.type))\n",
    "class failing(action):\n",
    "    type='失败'\n",
    "    def getmanconclusion(self,person):\n",
    "        printinfo('%s%s时，闷头喝酒，谁也不用说'%(person.type,self.type))\n",
    "    def getwomanconclusion(self,person):\n",
    "        printinfo('%s%s,眼泪汪汪，谁也说不了'%(person.type,self.type))\n",
    "class love(action):\n",
    "    type='恋爱'\n",
    "    def getmanconclusion(self,person):\n",
    "        printinfo('%s%s时，凡是不懂也要装懂'%(person.type,self.type))\n",
    "    def getwomanconclusion(self,person):\n",
    "        printinfo('%s%s时，懂事情也要装不懂'%(person.type,self.type))\n",
    "class objectstructure:\n",
    "    elements=[]\n",
    "    def attach(self,element):\n",
    "        self.elements.append(element)\n",
    "    def detach(self,element):\n",
    "        self.elements.remove(element)\n",
    "    def display(self,visitor):\n",
    "        for e in self.elements:\n",
    "            e.accept(visitor)\n",
    "def clientui():\n",
    "    o=objectstructure()\n",
    "    o.attach(man())\n",
    "    o.attach(woman())\n",
    "    \n",
    "    o.display(success())\n",
    "    o.display(failing())\n",
    "    o.display(love())\n",
    "    return\n",
    "\n",
    "if __name__=='__main__':\n",
    "    clientui()\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
